home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- import dns.exception as dns
-
- class BadTTL(dns.exception.SyntaxError):
- pass
-
-
- def from_text(text):
- if text.isdigit():
- total = long(text)
- elif not text[0].isdigit():
- raise BadTTL
-
- total = 0x0L
- current = 0x0L
- for c in text:
- if c.isdigit():
- current *= 10
- current += long(c)
- continue
- c = c.lower()
- if c == 'w':
- total += current * 0x93A80L
- elif c == 'd':
- total += current * 0x15180L
- elif c == 'h':
- total += current * 0xE10L
- elif c == 'm':
- total += current * 0x3CL
- elif c == 's':
- total += current
- else:
- raise BadTTL, "unknown unit '%s'" % c
- current = 0
-
- if not current == 0:
- raise BadTTL, 'trailing integer'
-
- if total < 0x0L or total > 0x7FFFFFFFL:
- raise BadTTL, 'TTL should be between 0 and 2^31 - 1 (inclusive)'
-
- return total
-
-